package com.sskj.one.proxy;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.bulong.rudeness.RudenessScreenHelper;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.sskj.common.adapter.ItemClickSupport;
import com.sskj.common.box.decoration.DividerLineItemDecoration;
import com.sskj.lib.adapter.BaseAdapter;
import com.sskj.lib.adapter.ViewHolder;
import com.sskj.lib.base.BaseActivity;
import com.sskj.lib.util.ChineseNumber;
import com.sskj.one.R;
import com.sskj.one.bean.TeamLevelBean;

import butterknife.BindView;
import butterknife.ButterKnife;
import io.reactivex.Observable;
import io.reactivex.functions.Function;

/**
 * @author Hey
 * Create at  2019/06/29
 */
public class MoreLevelActivity extends BaseActivity<MoreLevelPresenter> {


    @BindView(R.id.tvTitle)
    TextView tvTitle;
    @BindView(R.id.recyclerView)
    RecyclerView recyclerView;
    @BindView(R.id.smartRefreshView)
    SmartRefreshLayout smartRefreshView;

    private BaseAdapter<String> adapter;

    @Override
    public int getLayoutId() {
        return R.layout.app_activity_more_level;
    }

    @Override
    public MoreLevelPresenter getPresenter() {
        return new MoreLevelPresenter();
    }

    @Override
    public void initView() {
        tvTitle.setText("团队分级");
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        recyclerView.addItemDecoration(new DividerLineItemDecoration(this)
                .setPaintWidth((int) RudenessScreenHelper.pt2px(this, 20))
                .setFirstDraw(true)
                .setLastDraw(true)
                .setPaintColor(Color.TRANSPARENT));
        adapter = new BaseAdapter<String>(R.layout.item_more_level, null, recyclerView, true) {
            @Override
            public void bind(ViewHolder holder, String item) {
                holder.setText(R.id.tv_level, item)
                        .setText(R.id.tv_team_num, "0人");
            }
        };
        /**
         * 假数据
         */
        Observable.rangeLong(1, 15)
                .map(i -> ChineseNumber.NumberToChn(Integer.valueOf(i + "")) + "级")
                .toList()
                .subscribe(strings -> adapter.setNewData(strings));
        ItemClickSupport.addTo(recyclerView).setOnItemClickListener((recyclerView, position, v) -> DetailTeamActivity.start(MoreLevelActivity.this, position + 1 + ""));
    }

    @Override
    public void initData() {

    }

    public static void start(Context context) {
        Intent intent = new Intent(context, MoreLevelActivity.class);
        context.startActivity(intent);
    }

}
